import { CEventMgr } from "../framework/inc/ceventmgr";
import { ENUM_EVTID } from "./evtids";
// import { RunLand } from "./component/runland";
/*global Ammo */

let TEST = true;

let ENUM_GAME_STATUS = {
    start: 1,
    running: 2,
    onpause: 3,
    onfinish: 4,
    test: 99
};

let CONST_PHYICS_RADTIO = -9.8;

export class GameCtl {
    constructor(oWorld) {
        this._status = ENUM_GAME_STATUS["start"];
        this._worldgraph = oWorld;
        // this._worldphysic = this.__crt_physics_world();
    }
    __crt_physics_world() {
        let collisionConfiguration = new Ammo.btSoftBodyRigidBodyCollisionConfiguration();
        let dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration);
        let broadphase = new Ammo.btDbvtBroadphase();
        let solver = new Ammo.btSequentialImpulseConstraintSolver();
        let softBodySolver = new Ammo.btDefaultSoftBodySolver();
        let physicsWorld = new Ammo.btSoftRigidDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration, softBodySolver);
        physicsWorld.setGravity(new Ammo.btVector3(0, CONST_PHYICS_RADTIO, 0));
        physicsWorld.getWorldInfo().set_m_gravity(new Ammo.btVector3(0, CONST_PHYICS_RADTIO, 0));
    }
    __crt_one_treeland() {
        // let obj_land = new
    }
    registerEvt() {
        CEventMgr.Instance().dispatch(ENUM_EVTID["EVT_UISTART_RM"], () => {
            this.start();
        });
    }
    startGame() {
        if (TEST) {
            this._worldgraph.showTest();
            return;
        }
        this._worldgraph.showStartUI();
    }
    onRun() {
        this.initPhysics();
        this._worldgraph.showAnimation();
    }


}